library(tidyverse)
library(magrittr)
library(lubridate)
library(scales)
library(matrixStats)
library(ggrepel)
library(broom)
library(glue)
library(jsonlite)
library(rvest)
library(RCurl)
library(pander)
library(plotly)
library(cowplot)
library(QuantTools)
library(ggfortify)
library(readxl)
library(httr)
panderOptions("big.mark", ",")
panderOptions("table.split.table", Inf)
panderOptions("table.style", "rmarkdown")
panderOptions("missing", "")
theme_set(theme_bw())
auStates <- c(
  ACT = "Australian Capital Territory",
  QLD = "Queensland",
  NSW = "New South Wales",
  VIC = "Victoria",
  SA = "South Australia",
  WA = "Western Australia",
  NT = "Northern Territory",
  TAS = "Tasmania"
)

Data Sources

getConfirmed <- function(state, .state_full = auStates){
  state <- str_to_lower(state)
  url <- glue("https://covidlive.com.au/report/daily-cases/{state}")
  url %>%
    read_html() %>%
    html_nodes("body") %>%
    xml_find_all("//table[contains(@class, 'DAILY-CASES')]") %>% 
    html_table() %>%
    .[[1]] %>%
    as_tibble() %>%
    dplyr::select(date = DATE, confirmed = CASES) %>%
    separate(date, into = c("day", "month")) %>%
    mutate(
      year = year(today()),
      date = paste(year, month, day, sep = "-"),
      date = parse_date_time(date, orders = "%Y-%B-%d"),
      date = ymd(date),
      confirmed = str_remove_all(confirmed, ","),
      confirmed = as.numeric(confirmed),
      State = .state_full[str_to_upper(state)],
      Country = "Australia"
    ) %>%
    dplyr::select(State, Country, date, confirmed) %>%
    arrange(date) 
}
confirmed <- names(auStates) %>%
  lapply(getConfirmed) %>%
  bind_rows()
getRecovered <- function(state, .state_full = auStates){
  state <- str_to_lower(state)
  url <- glue("https://covidlive.com.au/report/daily-recoveries/{state}")
  url %>%
    read_html() %>%
    html_nodes("body") %>%
    xml_find_all("//table[contains(@class, 'DAILY-RECOVERIES')]") %>% 
    html_table() %>%
    .[[1]] %>%
    as_tibble() %>%
    dplyr::select(date = DATE, recovered = RECOV) %>%
    separate(date, into = c("day", "month")) %>%
    mutate(
      year = year(today()),
      date = paste(year, month, day, sep = "-"),
      date = parse_date_time(date, orders = "%Y-%B-%d"),
      date = ymd(date),
      recovered = str_remove_all(recovered, ","),
      recovered = as.numeric(recovered),
      State = .state_full[str_to_upper(state)],
      Country = "Australia"
    ) %>%
    dplyr::select(State, Country, date, recovered) %>%
    arrange(date) 
}
recovered <- names(auStates) %>%
  lapply(getRecovered) %>%
  bind_rows()
getDeaths <- function(state, .state_full = auStates){
  state <- str_to_lower(state)
  url <- glue("https://covidlive.com.au/report/daily-deaths/{state}")
  url %>%
    read_html() %>%
    html_nodes("body") %>%
    xml_find_all("//table[contains(@class, 'DAILY-DEATHS')]") %>% 
    html_table() %>%
    .[[1]] %>%
    as_tibble() %>%
    dplyr::select(date = DATE, deaths = DEATHS) %>%
    separate(date, into = c("day", "month")) %>%
    mutate(
      year = year(today()),
      date = paste(year, month, day, sep = "-"),
      date = parse_date_time(date, orders = "%Y-%B-%d"),
      date = ymd(date),
      deaths = str_remove_all(deaths, ","),
      deaths = as.numeric(deaths),
      State = .state_full[str_to_upper(state)],
      Country = "Australia"
    ) %>%
    dplyr::select(State, Country, date, deaths) %>%
    arrange(date) 
}
deaths <- names(auStates) %>%
  lapply(getDeaths) %>%
  bind_rows()
getActive <- function(state, .state_full = auStates){
  state <- str_to_lower(state)
  url <- glue("https://covidlive.com.au/report/daily-active-cases/{state}")
  url %>%
    read_html() %>%
    html_nodes("body") %>%
    xml_find_all("//table[contains(@class, 'DAILY-ACTIVE-CASES')]") %>% 
    html_table() %>%
    .[[1]] %>%
    as_tibble() %>%
    dplyr::select(date = DATE, active = ACTIVE) %>%
    separate(date, into = c("day", "month")) %>%
    mutate(
      year = year(today()),
      date = paste(year, month, day, sep = "-"),
      date = parse_date_time(date, orders = "%Y-%B-%d"),
      date = ymd(date),
      active = str_remove_all(active, ","),
      active = as.numeric(active),
      State = .state_full[str_to_upper(state)],
      Country = "Australia"
    ) %>%
    dplyr::select(State, Country, date, active) %>%
    arrange(date) 
}
active <- names(auStates) %>%
  lapply(getActive) %>%
  bind_rows()
getTested <- function(state, .state_full = auStates){
  state <- str_to_lower(state)
  url <- glue("https://covidlive.com.au/report/daily-tests/{state}")
  url %>%
    read_html() %>%
    html_nodes("body") %>%
    xml_find_all("//table[contains(@class, 'DAILY-TESTS')]") %>% 
    html_table() %>%
    .[[1]] %>%
    as_tibble() %>%
    dplyr::select(date = DATE, tests = TESTS) %>%
    separate(date, into = c("day", "month")) %>%
    mutate(
      year = year(today()),
      date = paste(year, month, day, sep = "-"),
      date = parse_date_time(date, orders = "%Y-%B-%d"),
      date = ymd(date),
      tests = str_remove_all(tests, ","),
      tests = as.numeric(tests),
      State = .state_full[str_to_upper(state)],
      Country = "Australia"
    ) %>%
    dplyr::select(State, Country, date, tests) %>%
    arrange(date) 
}
tested <- names(auStates) %>%
  lapply(getTested) %>%
  bind_rows() %>%
  dplyr::filter(!is.na(tests))

Data for confirmed cases, active cases, recoveries and fatalities was exclusively sourced from COVID LIVE.

International Data

International data and figures can be viewed here

dt <- max(confirmed$date)
dt_char <- as.character(dt)

Latest Australian Data

ausPops <- tribble(
  ~State, ~Population,
  "New South Wales",    8117976,
  "Victoria", 6629870,
  "Queensland", 5115451,
  "South Australia", 1756494,
  "Western Australia", 2630557,
  "Tasmania", 535500,
  "Northern Territory", 245562,
  "Australian Capital Territory", 428060
)

Australian State populations were taken from the ABS Website and were accurate in Sept 2019.

  • Using an estimated population size of 25,459,470, the total percentage of the Australian population confirmed as having been infected currently sits at 0.11%, or one person in every 904.
  • Within Victoria, that rises to one in every 326 having contracted the virus at some point
confirmed %>% 
  left_join(recovered) %>%
  left_join(deaths) %>%
  left_join(active) %>%
  dplyr::filter(
    date >= max(date) - 1
  ) %>%
  group_by(State) %>%
  mutate(
    Increase = c(NA, diff(confirmed)),
    `% Increase` = Increase / min(confirmed),
    recovered = c(NA, max(recovered)),
    deaths = c(NA, max(deaths)),
    active = c(NA, active[2])
  ) %>%
  ungroup() %>%
  pivot_wider(
    id_cols = State, 
    names_from = date, 
    values_from = c(confirmed, recovered, deaths, active, Increase, `% Increase`)
  ) %>%
  dplyr::select_if(function(x){sum(is.na(x)) <= 1}) %>%
  rename_all(
    str_remove_all, pattern = "confirmed_"
  ) %>%
  rename_all(str_remove_all, pattern = "_202[01].+") %>%
  bind_rows(
    tibble(
      State = "National Total",
      "{as.character(dt -1)}" := sum(.[[as.character(dt -1)]]),
      "{dt_char}" := sum(.[[dt_char]]),
      Increase = sum(.$Increase),
      recovered = sum(.$recovered),
      deaths = sum(.$deaths),
      active = sum(.$active),
      `% Increase` = Increase / !!sym(as.character(dt - 1))
    )
  ) %>%
  mutate(
    `% Increase` = percent(`% Increase`, accuracy = 0.01),
    `Fatality Rate` = percent(deaths / !!sym(dt_char), accuracy = 0.1),
    `Recovery Rate` = percent(recovered / !!sym(dt_char), accuracy = 0.1),
  ) %>%
  rename(
    Fatalities = deaths,
    Recovered = recovered,
    `Currently Active` = active
  ) %>%
  dplyr::select(
    State, starts_with("20"), ends_with("Increase"), starts_with("Fatal"), starts_with("Recov"), `Currently Active`
  ) %>%
  pander(
    justify = "lrrrrrrrrr",
    caption = paste(
      "*Confirmed cases, fatalities and recoveries reported by each state at time of preparation.",
      "Any states with unchanged, or decreasing confirmed cases may indicate delays with the automated data sources, such as health.gov.au or JHU, or that these states have not yet reported for the day.", 
      "Please note that some discrepancy with dates may occur due to automated data sources obtained different time zones, such as the USA, the UK and Australia.*"
    ),
    emphasize.strong.rows = nrow(.)
  )

Joining, by = c(“State”, “Country”, “date”) Joining, by = c(“State”, “Country”, “date”) Joining, by = c(“State”, “Country”, “date”)

Confirmed cases, fatalities and recoveries reported by each state at time of preparation. Any states with unchanged, or decreasing confirmed cases may indicate delays with the automated data sources, such as health.gov.au or JHU, or that these states have not yet reported for the day. Please note that some discrepancy with dates may occur due to automated data sources obtained different time zones, such as the USA, the UK and Australia.
State 2020-12-19 2020-12-20 Increase % Increase Fatalities Fatality Rate Recovered Recovery Rate Currently Active
Australian Capital Territory 117 118 1 0.85% 3 2.5% 114 96.6% 1
Queensland 1,232 1,234 2 0.16% 6 0.5% 1,214 98.4% 11
New South Wales 4,712 4,748 36 0.76% 53 1.1% 3,192 67.2% 72
Victoria 20,354 20,356 2 0.01% 820 4.0% 19,524 95.9% 12
South Australia 563 566 3 0.53% 4 0.7% 559 98.8% 3
Western Australia 845 845 0 0.00% 9 1.1% 825 97.6% 11
Northern Territory 71 71 0 0.00% 0 0.0% 59 83.1% 12
Tasmania 234 234 0 0.00% 13 5.6% 221 94.4% 0
National Total 28,128 28,172 44 0.16% 908 3.2% 25,708 91.3% 122

Plot of Current Australian Values

ausStatsCap <- "*Current confirmed and recovered cases, along with fatalities for Australia only. Active cases are shown as confirmed cases excluding fatalities and those classed as recovered. Loess curves through all points are shown as continuous lines. Data is only shown from 1^st^ April 2020 as this was the first date of complete data being available. Recovered patient information was also sparse in the early stages of data collection, and as a result estimates of active infections will be a significant underestimate until 6^th^ April. In particular, QLD only began reporting recovered cases on this date. NSW followed a fortnight after this date and as such, only the most recent numbers can be considered as accurate. Below this plot, the same figures can be seen broken down by state.*"
ggplotly(
  confirmed %>%
    left_join(deaths) %>%
    left_join(recovered) %>%
    left_join(active) %>%
    mutate_at(vars(confirmed, deaths, recovered, active), na_locf) %>%
    group_by(Country, date) %>%
    summarise_at(vars(confirmed, deaths, recovered, active), sum) %>%
    ungroup() %>%
    pivot_longer(
      cols = c(active, confirmed, deaths, recovered),
      names_to = "Status",
      values_to = "Total"
    ) %>%
    arrange(Status, date) %>%
    dplyr::filter(date > ymd("2020-04-01")) %>%
    mutate(
      Status = str_to_title(Status),
      Status = str_replace_all(Status, "Deaths", "Fatal"),
      Status = factor(Status, levels = c("Fatal", "Recovered", "Active"))
    ) %>%
    dplyr::filter(Total > 0) %>%
    rename_all(str_to_title) %>%
    dplyr::filter(Status != "Confirmed") %>%
    ggplot(aes(Date, Total, fill = Status)) +
    geom_col() +
    geom_line(
      data = . %>%
        group_by(Date) %>%
        summarise(
          Total = sum(Total)
        ) %>%
        mutate(Status = "Confirmed"),
      colour = "blue"
    ) +
    scale_fill_manual(
      values = c(
        Active = rgb(0, 0, 0),
        Confirmed = rgb(0, 0.3, 0.7),
        Fatal = rgb(0.8, 0.2, 0.2),
        Recovered = rgb(0.2, 0.7, 0.4)
      )
    ) +
    scale_x_date(expand = expansion(c(0, 0.03))) +
    scale_y_continuous(expand = expansion(c(0, 0.05))) +
    labs("Total Cases")
)

Current confirmed and recovered cases, along with fatalities for Australia only. Active cases are shown as confirmed cases excluding fatalities and those classed as recovered. Loess curves through all points are shown as continuous lines. Data is only shown from 1st April 2020 as this was the first date of complete data being available. Recovered patient information was also sparse in the early stages of data collection, and as a result estimates of active infections will be a significant underestimate until 6th April. In particular, QLD only began reporting recovered cases on this date. NSW followed a fortnight after this date and as such, only the most recent numbers can be considered as accurate. Below this plot, the same figures can be seen broken down by state.

ggplotly(
  confirmed %>%
    left_join(deaths) %>%
    left_join(recovered) %>%
    left_join(active) %>%
    mutate_at(vars(confirmed, deaths, recovered, active), na_locf) %>%
    dplyr::filter(
      date > ymd("2020-04-01"),
    ) %>%
    arrange(date) %>%
    left_join(ausPops) %>%
    pivot_longer(
      cols = c(confirmed, deaths, recovered, active),
      names_to = "status",
      values_to = "count"
    ) %>%
    dplyr::filter(
      count > 0,
      !(State %in% c("Queensland", "New South Wales") & status == "recovered" & date < ymd("2020-04-06")),
      !(State %in% c("South Australia") & status == "recovered" & date < ymd("2020-04-01")),    
      !(State %in% c("Tasmania") & status == "recovered" & date < ymd("2020-04-02")),
    ) %>%
    dplyr::filter(status != "confirmed") %>%
    mutate(
      rate = 1e6*count/Population,
      rate = round(rate, 2),
      status = str_replace(status, "deaths", "fatal") %>% str_to_title(),
      status = factor(status, levels = c("Fatal", "Recovered", "Active"))
    ) %>%
    rename_all(str_to_title) %>%
    ggplot(aes(Date, Rate, fill = Status, label = Count)) +
    geom_col() +
    geom_line(
      data = . %>%
        group_by(State, Date) %>%
        summarise(
          Rate = sum(Rate),
          Count = sum(Count)
        ) %>%
        mutate(Status = "Confirmed"),
      colour = "blue"
    ) +
    facet_wrap(~State, ncol = 4) + 
    scale_fill_manual(
      values = c(
        Active = rgb(0, 0, 0),
        Confirmed = rgb(0, 0.3, 0.7),
        Fatal = rgb(0.8, 0.2, 0.2),
        Recovered = rgb(0.2, 0.7, 0.4)
      )
    ) +
    scale_x_date(expand = expansion(c(0, 0.03))) +
    labs(y = "Rate (Cases / Million)")
)

Breakdown of individual states. Victorian recovered numbers began to be accurately reported from 22nd March, with other states gradually providing this information. NSW/QLD recovered cases have only recently begun being reported and up until the most recent dates, recovered/active values were very approximate for these states. The extreme drop for NSW active cases in early June is a function of the changed reporting strategy implemented by NSW Health.

Daily New Cases

ggplotly(
  confirmed %>%
    group_by(State) %>%
    mutate(daily = c(0, diff(confirmed))) %>%
    ungroup() %>%
    dplyr::filter(confirmed > 0) %>%
    mutate(
      daily = case_when(
        daily < 0 ~ 0,
        daily >= 0 ~ daily
      )
    ) %>%
    bind_rows(
      group_by(., date) %>%
        summarise(daily = sum(daily)) %>%
        ungroup() %>%
        mutate(State = "All States")
    ) %>%
    group_by(State) %>%
    mutate(
      MA = round(sma(daily, 7), 2),
      MA2 = round(sma(daily, 14), 2),
      `Above Average` = MA > MA2
    ) %>%
    dplyr::filter(date > "2020-03-01") %>%
    ggplot(aes(date, daily)) +
    geom_col(
      aes(fill = `Above Average`, colour = `Above Average`),
      data = . %>% dplyr::filter(!is.na(`Above Average`)),
      width = 1/2
    ) +
    geom_line(aes(y = MA), colour = "blue") +
    geom_line(aes(y = MA2), colour = "black") +
    facet_wrap(~State, scales = "free_y") +
    labs(
      x = "Date",
      y = "Daily New Cases",
      fill = "\nAbove\nAverage"
    ) +
    scale_fill_manual(values = c("white", rgb(1, 0.2, 0.2))) +
    scale_colour_manual(values = c("grey50", rgb(1, 0.2, 0.2))),
  tooltip = c(
    "date", "daily", "MA"
  )
)

Daily new cases for each state shown against the 7-day (blue) and 14-day (black) averages. Days which the 7-day average is above the 14-day average are highlighted in red.

Australian Fatality Rate

inc <- 6
icu <- 11
d <- 7
offset <- icu + d 
minDate <- "2020-04-20"
list(
  confirmed %>%
    group_by(date) %>%
    summarise_at("confirmed", sum) %>%
    left_join(
      deaths %>%
        group_by(date) %>%
        summarise_at("deaths", sum) 
    ) %>%
    dplyr::filter(
      date > minDate
    ) %>%
    mutate(
      fr = deaths / confirmed,
      type = "No Offset"
    ),
  confirmed %>%
    mutate(
      date = date + offset 
    ) %>%
    group_by(date) %>%
    summarise_at("confirmed", sum) %>%
    left_join(
      deaths %>%
        group_by(date) %>%
        summarise_at("deaths", sum) 
    ) %>%
    dplyr::filter(
      date > minDate
    ) %>%
    mutate(
      fr = deaths / confirmed,
      type = glue("Offset ({offset} days)")
    ) 
) %>%
  bind_rows() %>%
  ggplot(
    aes(date, fr, colour = type)
  ) +
  geom_line() +
  scale_x_date(
    expand = expansion(mult = 0, add = 0)
  ) +
  scale_y_continuous(label = percent) +
  labs(
    x = "Date",
    y = "Estimated Fatality Rate",
    colour = "Calculation"
  )
*Fatality rate for Australian cases as calculated using two methods.
Where no offset is included, the rate shown is simply the number of fatalities divided by the total number of reported cases on the same date.
When cases increase during a new outbreak, this will skew the fatality rate lower.
An alternative is to use an offset based on the fact the the median time from infection to symptom onset is 6 days, the median time from symptom onset to ICU admission is 11 days, and the median time from ICU admission to mortality is 7 days.
When using the offset, the fatality rate is calculated as the number of recorded fatalities on a given date, divided by by the number of cases from 18 days ago.
Whilst still flawed this may give a less biased estimate on the true fatality rate, and importantly, will always be higher than the alternative calculation.
The intial fatality rate spiked above 30% during the intial outbreak under the offset approach, and as such, data is only shown after 20 Apr, 2020.
All times used for estimation the offset were obtained from [here](https://wwwnc.cdc.gov/eid/article/26/6/20-0320_article)*

Fatality rate for Australian cases as calculated using two methods. Where no offset is included, the rate shown is simply the number of fatalities divided by the total number of reported cases on the same date. When cases increase during a new outbreak, this will skew the fatality rate lower. An alternative is to use an offset based on the fact the the median time from infection to symptom onset is 6 days, the median time from symptom onset to ICU admission is 11 days, and the median time from ICU admission to mortality is 7 days. When using the offset, the fatality rate is calculated as the number of recorded fatalities on a given date, divided by by the number of cases from 18 days ago. Whilst still flawed this may give a less biased estimate on the true fatality rate, and importantly, will always be higher than the alternative calculation. The intial fatality rate spiked above 30% during the intial outbreak under the offset approach, and as such, data is only shown after 20 Apr, 2020. All times used for estimation the offset were obtained from here

Current Growth Factor

n <- 14
cp <- glue(
  "*Growth factor for each State/Territory. 
  This value becomes volatile when daily new cases approach zero as is commonly observed in small populations, and at the end stages of an outbreak. 
  Given the multiple updates during the course of the day, values shown represent those up to the previous day.
  In order to try and minimise volatility a {n} day simple moving average was used, in contrast to the 5 day average as advocated [here](https://www.abc.net.au/news/2020-04-10/coronavirus-data-australia-growth-factor-covid-19/12132478).
  This enables assessment of the growth factor over an entire quarantine period.
  If no new cases are observed over this period, the value is not able to be calculated.
  The dashed vertical lines indicate the day most state borders were closed.*"
)
gf <- list(
  confirmed %>%
    dplyr::filter(Country == "Australia", date < dt) %>%
    arrange(date) %>%
    group_by(State) %>%
    mutate(
      new = c(0, diff(confirmed)),
      new_ma = sma(new, n)
    ) %>%
    dplyr::filter(confirmed > 0, !is.na(new_ma)) %>%
    mutate(
      R = c(NA, new_ma[-1] / new_ma[-n()]),
      R = case_when(
        is.nan(R) ~ NA_real_,
        !is.nan(R) ~ R
      )
    ) %>%
    ungroup() %>%
    arrange(State),
  confirmed %>%
    dplyr::filter(Country == "Australia", date < dt) %>%
    arrange(date) %>%
    group_by(Country, date) %>%
    summarise_at(vars(confirmed), sum) %>%
    ungroup() %>%
    mutate(
      new = c(0, diff(confirmed)),
      new_ma = sma(new, n)
    ) %>%
    dplyr::filter(confirmed > 0, !is.na(new_ma)) %>%
    mutate(
      R = c(NA, new_ma[-1] / new_ma[-n()]),
      R = case_when(
        is.nan(R) ~ NA_real_,
        !is.nan(R) ~ R
      ),
      State = "All States"
    ) %>%
    arrange(State)
) %>%
  bind_rows() %>%
  dplyr::filter(date > ymd("2020-03-15")) %>%
  ggplot(aes(date, R, colour = State)) +
  geom_ribbon(aes(ymin = 1, ymax = R), alpha = 0.1) +
  geom_hline(yintercept = 1) +
  geom_vline(
    xintercept = ymd("2020-03-22"),
    linetype = 2,
    colour = "grey30"
  ) +
  geom_label(
    aes(label = R),
    data = . %>%
      dplyr::filter(date == max(date)) %>%
      mutate(R = round(R, 2), date = date + 1),
    fill = rgb(1, 1, 1, 0.3),
    show.legend = FALSE,
    nudge_y = 0.3,
    size = 4
  ) +
  labs(
    x = "Date", y = "Growth Factor"
  ) +
  facet_wrap(~State, scales = "free_x") +
  theme(legend.position = "none") +
  coord_cartesian(ylim = c(0.4, 2.1))
gf
*Growth factor for each State/Territory. 
This value becomes volatile when daily new cases approach zero as is commonly observed in small populations, and at the end stages of an outbreak. 
Given the multiple updates during the course of the day, values shown represent those up to the previous day.
In order to try and minimise volatility a 14 day simple moving average was used, in contrast to the 5 day average as advocated [here](https://www.abc.net.au/news/2020-04-10/coronavirus-data-australia-growth-factor-covid-19/12132478).
This enables assessment of the growth factor over an entire quarantine period.
If no new cases are observed over this period, the value is not able to be calculated.
The dashed vertical lines indicate the day most state borders were closed.*

Growth factor for each State/Territory. This value becomes volatile when daily new cases approach zero as is commonly observed in small populations, and at the end stages of an outbreak. Given the multiple updates during the course of the day, values shown represent those up to the previous day. In order to try and minimise volatility a 14 day simple moving average was used, in contrast to the 5 day average as advocated here. This enables assessment of the growth factor over an entire quarantine period. If no new cases are observed over this period, the value is not able to be calculated. The dashed vertical lines indicate the day most state borders were closed.

The current 14 day growth factor is 1.19 which gives considerable cause for concern..

Testing Within Each State

tested %>% 
  left_join(confirmed, by = c("State", "Country", "date") ) %>%
  dplyr::filter(date == dt) %>%
  left_join(ausPops,  by = "State") %>%
  bind_rows(
    tibble(
      State = "National Total",
      date = dt,
      Population = sum(.$Population, na.rm = TRUE),
      confirmed = sum(.$confirmed, na.rm = TRUE),
      tests = sum(.$tests, na.rm = TRUE)
    )
  ) %>%
  mutate(
    `Tests / '000` = round(1e3 * tests / Population, 2),
    Positive = confirmed / tests,
    Negative = 1 - Positive,
    isTotal = grepl("Total", State)
  ) %>%
  dplyr::select(
    State, Population,
    Confirmed = confirmed,
    Tests = tests, 
    contains("000"), 
    ends_with("ive"),
    isTotal
  ) %>%
  arrange(isTotal, desc(`Tests / '000`)) %>%
  dplyr::select(-isTotal) %>%
  dplyr::rename(
    `% Positive Tests` = Positive,
    `% Negative Tests` = Negative
  ) %>%
  mutate_at(
    vars(starts_with("%")), percent, accuracy = 0.01
  ) %>%
  pander(
    justify = "lrrrrrr",
    missing = "",
    caption = glue(
      "*COVID-19 testing scaled by state population size.
      Confirmed cases are assumed to be the tests returning a positive result.
      The current numbers available for some states are a lower limit, and as such, the proportion of the population tested is likely to be higher, as is the proportion of tests returning a negative result.*"
    ),
    emphasize.strong.rows = nrow(.)
  )
COVID-19 testing scaled by state population size. Confirmed cases are assumed to be the tests returning a positive result. The current numbers available for some states are a lower limit, and as such, the proportion of the population tested is likely to be higher, as is the proportion of tests returning a negative result.
State Population Confirmed Tests Tests / ’000 % Positive Tests % Negative Tests
Victoria 6,629,870 20,356 3,747,703 565.3 0.54% 99.46%
New South Wales 8,117,976 4,748 3,692,747 454.9 0.13% 99.87%
South Australia 1,756,494 566 782,636 445.6 0.07% 99.93%
Northern Territory 245,562 71 77,941 317.4 0.09% 99.91%
Australian Capital Territory 428,060 118 129,169 301.8 0.09% 99.91%
Queensland 5,115,451 1,234 1,417,134 277 0.09% 99.91%
Tasmania 535,500 234 137,693 257.1 0.17% 99.83%
Western Australia 2,630,557 845 596,371 226.7 0.14% 99.86%
National Total 25,459,470 28,172 10,581,394 415.6 0.27% 99.73%

R Session Information

R version 4.0.3 (2020-10-10)

Platform: x86_64-pc-linux-gnu (64-bit)

locale: LC_CTYPE=C, LC_NUMERIC=C, LC_TIME=C, LC_COLLATE=C, LC_MONETARY=C, LC_MESSAGES=en_AU.UTF-8, LC_PAPER=en_AU.UTF-8, LC_NAME=C, LC_ADDRESS=C, LC_TELEPHONE=C, LC_MEASUREMENT=en_AU.UTF-8 and LC_IDENTIFICATION=C

attached base packages: stats, graphics, grDevices, utils, datasets, methods and base

other attached packages: httr(v.1.4.2), readxl(v.1.3.1), ggfortify(v.0.4.11), QuantTools(v.0.5.7.1), data.table(v.1.13.4), cowplot(v.1.1.0), plotly(v.4.9.2.1), pander(v.0.6.3), RCurl(v.1.98-1.2), rvest(v.0.3.6), xml2(v.1.3.2), jsonlite(v.1.7.2), glue(v.1.4.2), broom(v.0.7.2), ggrepel(v.0.8.2), matrixStats(v.0.57.0), scales(v.1.1.1), lubridate(v.1.7.9.2), magrittr(v.2.0.1), forcats(v.0.5.0), stringr(v.1.4.0), dplyr(v.1.0.2), purrr(v.0.3.4), readr(v.1.4.0), tidyr(v.1.1.2), tibble(v.3.0.4), ggplot2(v.3.3.2) and tidyverse(v.1.3.0)

loaded via a namespace (and not attached): Rcpp(v.1.0.5), assertthat(v.0.2.1), digest(v.0.6.27), R6(v.2.5.0), cellranger(v.1.1.0), backports(v.1.2.1), reprex(v.0.3.0), evaluate(v.0.14), highr(v.0.8), pillar(v.1.4.7), rlang(v.0.4.9), curl(v.4.3), lazyeval(v.0.2.2), rstudioapi(v.0.13), rmarkdown(v.2.5), labeling(v.0.4.2), selectr(v.0.4-2), htmlwidgets(v.1.5.3), munsell(v.0.5.0), compiler(v.4.0.3), modelr(v.0.1.8), xfun(v.0.19), pkgconfig(v.2.0.3), htmltools(v.0.5.0), tidyselect(v.1.1.0), gridExtra(v.2.3), fasttime(v.1.0-2), fansi(v.0.4.1), viridisLite(v.0.3.0), crayon(v.1.3.4), dbplyr(v.2.0.0), withr(v.2.3.0), bitops(v.1.0-6), grid(v.4.0.3), gtable(v.0.3.0), lifecycle(v.0.2.0), DBI(v.1.1.0), cli(v.2.2.0), stringi(v.1.5.3), farver(v.2.0.3), fs(v.1.5.0), ellipsis(v.0.3.1), generics(v.0.1.0), vctrs(v.0.3.5), Cairo(v.1.5-12.2), tools(v.4.0.3), crosstalk(v.1.1.0.1), hms(v.0.5.3), yaml(v.2.2.1), colorspace(v.2.0-0), knitr(v.1.30) and haven(v.2.3.1)